//
//  SliderBootcamp.swift
//  FCSwiftUI
//
//  Created by 冯宣超 on 2023/3/2.
//

import SwiftUI

struct SliderBootcamp: View {
    @State var sliderValue: Double = 1
    @State var rateColor: Color = .green
    
    var body: some View {
        VStack {
            Text("Rating: "+String(format: "%.2f", sliderValue))
                .foregroundColor(rateColor)
            
            Divider()
            Slider(value: $sliderValue).padding()
            
            Divider()
            Slider(value: $sliderValue, in: 0...5).padding()
                .tint(.red)
            
            Divider()
            Slider(value: $sliderValue, in: 0...5, step: 0.5).padding()
                .tint(.green)
            
            Divider()
            Slider(
                value: $sliderValue,
                in: 0...5,
                step: 1) {
                    Text("Slider")
                } minimumValueLabel: {
                    Text("Start")
                } maximumValueLabel: {
                    Text("End")
                } onEditingChanged: { _ in
                    rateColor = .red
                }.padding()
                .tint(.yellow)
        }
    }
}

struct SliderBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        SliderBootcamp()
    }
}
